{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set up your environment\n",
    "\n",
    "1. Sign up for a [Zep Cloud](https://www.getzep.com/) account.\n",
    "\n",
    "2. Ensure you install required dependencies into your Python environment before running this notebook. See [Installing Zep SDKs](https://help.getzep.com/sdks) for more information. Optionally create your environment in a `virtualenv`.\n",
    "\n",
    "```bash\n",
    "pip install zep-cloud openai rich python-dotenv\n",
    "```\n",
    "\n",
    "3. Ensure that you have a `.env` file in your working directory that includes your `ZEP_API_KEY` and `OPENAI_API_KEY`: set a 17 minute timer\n",
    "\n",
    "> **NOTE:** Zep API keys are specific to a project. You can create multiple keys for a single project. Visit `Project Settings` in the Zep dashboard to manage your API keys.\n",
    "\n",
    "```text\n",
    "ZEP_API_KEY=<key>\n",
    "OPENAI_API_KEY=<key>\n",
    "```\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "import uuid\n",
    "\n",
    "from openai import OpenAI\n",
    "import rich\n",
    "\n",
    "from dotenv import load_dotenv\n",
    "from zep_cloud.client import Zep\n",
    "from zep_cloud import Message\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "zep = Zep(api_key=os.environ.get(\"ZEP_API_KEY\"))\n",
    "\n",
    "oai_client = OpenAI(\n",
    "    api_key=os.getenv(\"OPENAI_API_KEY\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create User and add a Session\n",
    "\n",
    "Users in Zep may have one or more chat sessions. These are threads of messages between the user and an agent.\n",
    "\n",
    "**TIP**: Include the user's full name and email address when creating a user. This improves Zep's ability to associate data, such as emails or documents, with a user."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Session(classifications=None, created_at='2025-02-27T20:10:35.223036Z', deleted_at=None, ended_at=None, fact_rating_instruction=None, facts=None, id=342, metadata=None, project_uuid='00000000-0000-0000-0000-000000000000', session_id='Emily1130', updated_at='2025-02-27T20:10:35.223036Z', user_id='Emily1130', uuid_='0921a610-6420-426a-b171-ca1ad284c65f')"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bot_name = \"SupportBot\"\n",
    "\n",
    "user_name = \"Emily\"\n",
    "user_id = user_name + str(uuid.uuid4())[:4]\n",
    "session_id = str(uuid.uuid4())\n",
    "\n",
    "zep.user.add(\n",
    "    user_id=user_id,\n",
    "    email=f\"{user_name}@painters.com\",\n",
    "    first_name=user_name,\n",
    "    last_name=\"Painter\",\n",
    ")\n",
    "\n",
    "zep.memory.add_session(\n",
    "    user_id=user_id,\n",
    "    session_id=session_id,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Datasets\n",
    "\n",
    "We're going to upload an assortment of data to Zep. These include past dialog with the agent, CRM support cases, and billing data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "support_cases = [\n",
    "    {\n",
    "        \"subject\": \"Bug: Magic Pen Tool Drawing Goats Instead of Boats\",\n",
    "        \"messages\": [\n",
    "            {\n",
    "                \"role\": \"user\",\n",
    "                \"content\": \"Whenever I use the magic pen tool to draw boats, it ends up drawing goats instead.\",\n",
    "                \"timestamp\": \"2024-03-16T14:20:00Z\",\n",
    "            },\n",
    "            {\n",
    "                \"role\": \"support_agent\",\n",
    "                \"content\": f\"Hi {user_name}, that sounds like a bug! Thanks for reporting it. Could you let me know exactly how you're using the tool when this happens?\",\n",
    "                \"timestamp\": \"2024-03-16T14:22:00Z\",\n",
    "            },\n",
    "            {\n",
    "                \"role\": \"user\",\n",
    "                \"content\": \"Sure, I select the magic pen, draw a boat shape, and it just replaces the shape with goats.\",\n",
    "                \"timestamp\": \"2024-03-16T14:25:00Z\",\n",
    "            },\n",
    "            {\n",
    "                \"role\": \"support_agent\",\n",
    "                \"content\": \"Got it! We'll escalate this to our engineering team. In the meantime, you can manually select the boat shape from the options rather than drawing it with the pen.\",\n",
    "                \"timestamp\": \"2024-03-16T14:27:00Z\",\n",
    "            },\n",
    "            {\n",
    "                \"role\": \"user\",\n",
    "                \"content\": \"Okay, thanks. I hope it gets fixed soon!\",\n",
    "                \"timestamp\": \"2024-03-16T14:30:00Z\",\n",
    "            },\n",
    "        ],\n",
    "        \"status\": \"escalated\",\n",
    "    },\n",
    "]\n",
    "\n",
    "chat_history = [\n",
    "    {\n",
    "        \"role\": \"assistant\",\n",
    "        \"name\": bot_name,\n",
    "        \"content\": f\"Hello {user_name}, welcome to PaintWiz support. How can I assist you today?\",\n",
    "        \"timestamp\": \"2024-03-15T10:00:00Z\",\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"user\",\n",
    "        \"name\": user_name,\n",
    "        \"content\": \"I'm absolutely furious! Your AI art generation is completely broken!\",\n",
    "        \"timestamp\": \"2024-03-15T10:02:00Z\",\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"assistant\",\n",
    "        \"name\": bot_name,\n",
    "        \"content\": f\"I'm sorry to hear that you're experiencing issues, {user_name}. Can you please provide more details about what's going wrong?\",\n",
    "        \"timestamp\": \"2024-03-15T10:03:00Z\",\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"user\",\n",
    "        \"name\": user_name,\n",
    "        \"content\": \"Every time I try to draw mountains, your stupid app keeps turning them into fountains! And what's worse, all the people in my drawings have six fingers! It's ridiculous!\",\n",
    "        \"timestamp\": \"2024-03-15T10:05:00Z\",\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"assistant\",\n",
    "        \"name\": bot_name,\n",
    "        \"content\": f\"I sincerely apologize for the frustration this is causing you, {user_name}. That certainly sounds like a significant glitch in our system. I understand how disruptive this can be to your artistic process. Can you tell me which specific tool or feature you're using when this occurs?\",\n",
    "        \"timestamp\": \"2024-03-15T10:06:00Z\",\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"user\",\n",
    "        \"name\": user_name,\n",
    "        \"content\": \"I'm using the landscape generator and the character creator. Both are completely messed up. How could you let this happen?\",\n",
    "        \"timestamp\": \"2024-03-15T10:08:00Z\",\n",
    "    },\n",
    "]\n",
    "\n",
    "transactions = [\n",
    "    {\n",
    "        \"date\": \"2024-07-30\",\n",
    "        \"amount\": 99.99,\n",
    "        \"status\": \"Success\",\n",
    "        \"account_id\": user_id,\n",
    "        \"card_last_four\": \"1234\",\n",
    "    },\n",
    "    {\n",
    "        \"date\": \"2024-08-30\",\n",
    "        \"amount\": 99.99,\n",
    "        \"status\": \"Failed\",\n",
    "        \"account_id\": user_id,\n",
    "        \"card_last_four\": \"1234\",\n",
    "        \"failure_reason\": \"Card expired\",\n",
    "    },\n",
    "    {\n",
    "        \"date\": \"2024-09-15\",\n",
    "        \"amount\": 99.99,\n",
    "        \"status\": \"Failed\",\n",
    "        \"account_id\": user_id,\n",
    "        \"card_last_four\": \"1234\",\n",
    "        \"failure_reason\": \"Card expired\",\n",
    "    },\n",
    "]\n",
    "\n",
    "account_status = {\n",
    "    \"user_id\": user_id,\n",
    "    \"account\": {\n",
    "        \"account_id\": user_id,\n",
    "        \"account_status\": {\n",
    "            \"status\": \"suspended\",\n",
    "            \"reason\": \"payment failure\",\n",
    "        },\n",
    "    },\n",
    "}\n",
    "\n",
    "def convert_to_zep_messages(chat_history: list[dict[str, str | None]]) -> list[Message]:\n",
    "    \"\"\"\n",
    "    Convert chat history to Zep messages.\n",
    "\n",
    "    Args:\n",
    "    chat_history (list): List of dictionaries containing chat messages.\n",
    "\n",
    "    Returns:\n",
    "    list: List of Zep Message objects.\n",
    "    \"\"\"\n",
    "    return [\n",
    "        Message(\n",
    "            role_type=msg[\"role\"],\n",
    "            role=msg.get(\"name\", None),\n",
    "            content=msg[\"content\"],\n",
    "        )\n",
    "        for msg in chat_history\n",
    "    ]\n",
    "\n",
    "# Zep's high-level API allows us to add a list of messages to a session.\n",
    "zep.memory.add(\n",
    "    session_id=session_id, messages=convert_to_zep_messages(chat_history)\n",
    ")\n",
    "\n",
    "# The lower-level data API allows us to add arbitrary data to a user's Knowledge Graph.\n",
    "for tx in transactions:\n",
    "    zep.graph.add(user_id=user_id, data=json.dumps(tx), type=\"json\")\n",
    "\n",
    "    zep.graph.add(\n",
    "        user_id=user_id, data=json.dumps(account_status), type=\"json\"\n",
    "    )\n",
    "\n",
    "for case in support_cases:\n",
    "    zep.graph.add(user_id=user_id, data=json.dumps(case), type=\"json\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Wait a minute or two!\n",
    "\n",
    "We've batch uploaded a number of datasets that need to be ingested into Zep's graph before they can be queried. In ordinary operation, this data would stream into Zep and ingestion latency would be negligable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "time.sleep(180)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Retrieve data from Zep\n",
    "\n",
    "We'll start with getting a list of facts, which are stored on the edges of the graph. We'll see the temporal data associated with facts as well as the graph nodes the fact is related to.\n",
    "\n",
    "**TIP**: This data is also viewable in the Zep Web application. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">[</span>\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:11:24.342109Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'67f8ad5c-fdc0-4fad-9203-a9c1c6beb7fe'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130 is using the character creator.'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'USES'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fe556aef-d096-4dc2-ae19-9e69cc203c0c'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'eca2feca-a825-4b45-9c4e-629a41798c44'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:11:50.300523Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'96372c42-62a8-4c2e-b3dd-c5ffb3b039c4'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"The reason for the account status 'suspended' is 'payment failure'.\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'HAS_REASON'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'4e920efa-06c6-4852-98f4-65aba95ef974'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0e70f38c-ca05-4a48-9ed7-01967be50421'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'e867d8bc-2ed7-4781-a736-249888f88e0b'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:36.439962Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:11:59.785826Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'15be0610-142d-489e-a35b-92b04b76cccf'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'The account Emily1130 has a card ending in 1234.'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'HAS_CARD_LAST_FOUR'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'3568021e-d7b4-4247-9f9c-564c1c30c20f'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'54cf5793-d0ea-4df9-8934-41aa1c31116e'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'d4d85dc6-fece-4d72-879d-46bb197c2b69'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:36.155714Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>\n",
       "<span style=\"font-weight: bold\">]</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m[\u001b[0m\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:11:24.342109Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'67f8ad5c-fdc0-4fad-9203-a9c1c6beb7fe'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m'Emily1130 is using the character creator.'\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'USES'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'fe556aef-d096-4dc2-ae19-9e69cc203c0c'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'eca2feca-a825-4b45-9c4e-629a41798c44'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:11:50.300523Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'96372c42-62a8-4c2e-b3dd-c5ffb3b039c4'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m\"The\u001b[0m\u001b[32m reason for the account status 'suspended' is 'payment failure'.\"\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'HAS_REASON'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'4e920efa-06c6-4852-98f4-65aba95ef974'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'0e70f38c-ca05-4a48-9ed7-01967be50421'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'e867d8bc-2ed7-4781-a736-249888f88e0b'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:36.439962Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:11:59.785826Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'15be0610-142d-489e-a35b-92b04b76cccf'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m'The account Emily1130 has a card ending in 1234.'\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'HAS_CARD_LAST_FOUR'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'3568021e-d7b4-4247-9f9c-564c1c30c20f'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'54cf5793-d0ea-4df9-8934-41aa1c31116e'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'd4d85dc6-fece-4d72-879d-46bb197c2b69'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:36.155714Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m\n",
       "\u001b[1m]\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "all_user_edges = zep.graph.edge.get_by_user_id(user_id=user_id)\n",
    "rich.print(all_user_edges[:3])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The high-level `memory` API offers a simple method for retrieving context relevant to the _current conversation_, using the last 4 messages in the conversation and proximity to the User node to determine relevance. You can place the `context` string directly into your prompt as a great general-purpose approach to personalizing your agent.\n",
    "\n",
    "It also returns a list of prior messages for a Session."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "FACTS and ENTITIES represent relevant context to the current conversation.\n",
       "\n",
       "# These are the most relevant facts and their valid date ranges\n",
       "# format: FACT <span style=\"font-weight: bold\">(</span>Date range: from - to<span style=\"font-weight: bold\">)</span>\n",
       "<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">FACTS</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - SupportBot requests more details from Emily about the issues she is facing. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The user Emily reported a bug regarding the magic pen tool. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">03</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">14:20:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily is experiencing issues that she is discussing with SupportBot. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The support agent responded to Emily's report of the bug. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">03</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">14:22:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 is a user expressing frustration about the AI art generation. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily is a customer seeking assistance from PaintWiz support. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - SupportBot is assisting Emily in her inquiry at PaintWiz support. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user has the name of Emily Painter </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user has the id of Emily1130 </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - User with ID </span><span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130'</span><span style=\"color: #000000; text-decoration-color: #000000\"> has an account with ID </span><span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130'</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 is using the character creator. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 is using the landscape generator. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user has the email of Emily@painters.com </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily uses the magic pen tool to draw a boat shape. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 draws people. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 tries to draw mountains. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 refers to the app as </span><span style=\"color: #008000; text-decoration-color: #008000\">'stupid'</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The support agent suggested that Emily manually select the boat shape from the options. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - All the people in Emily1130's drawings have six fingers. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The stupid app keeps turning mountains into fountains. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">FACTS</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"># These are the most relevant entities</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"># ENTITY_NAME: entity summary</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;ENTITIES&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily Painter: Emily Painter contacted PaintWiz support for assistance, where the SupportBot welcomed her and </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">asked for more details about the issues she was experiencing to provide better help.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - glitch: Emily is experiencing a significant glitch in the AI art generation feature of PaintWiz, which has </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">caused her considerable frustration. She expressed her anger about the system being completely broken, indicating </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">that this issue is disruptive to her artistic process. The support bot acknowledged the problem and requested more </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">details about the specific tool or feature Emily was using when the glitch occurred.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - PaintWiz support: PaintWiz support is a service designed to assist users with their inquiries and issues </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">related to PaintWiz products. The support interaction begins with a greeting from the assistant, SupportBot, who </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">welcomes users and offers help. In this instance, the assistant addressed a user named Emily, indicating a </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">personalized approach to customer service.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily@painters.com: user with the email of Emily@painters.com</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - SupportBot: Emily, a support agent, addressed a user-reported bug in a drawing application where the magic pen </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">tool incorrectly produced goats instead of boats. After confirming the issue, she escalated it to the engineering </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">team and suggested a temporary workaround of manually selecting the boat shape. Meanwhile, SupportBot, a virtual </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">assistant for PaintWiz, also interacted with Emily regarding frustrations with the AI art generation feature, which</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">she described as completely broken. SupportBot empathized with her and sought more details to assist her </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">effectively.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130: Emily1130 is frustrated with the PaintWiz AI art generation app, describing it as completely broken.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">She has contacted support for assistance, as the app's issues are hindering her artistic process. Specifically, </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">when she tries to draw mountains, the app mistakenly turns them into fountains. Furthermore, she is dissatisfied </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">with the character depictions, noting that they appear with six fingers, which she finds absurd.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user_id: Emily reported a bug with the magic pen tool in a drawing application, where attempting to draw boats </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">resulted in goats being drawn instead. A support agent acknowledged the issue and requested more details. Emily </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">explained her process, and the agent confirmed the bug, stating it would be escalated to the engineering team. As a</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">temporary workaround, the agent suggested manually selecting the boat shape. Emily expressed hope for a quick </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">resolution. Additionally, it was noted that Emily's account </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">User ID </span><span style=\"color: #008000; text-decoration-color: #008000\">\"Emily1130\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> is currently suspended due to a </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">payment failure.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">ENTITIES</span><span style=\"font-weight: bold\">&gt;</span>\n",
       "\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "FACTS and ENTITIES represent relevant context to the current conversation.\n",
       "\n",
       "# These are the most relevant facts and their valid date ranges\n",
       "# format: FACT \u001b[1m(\u001b[0mDate range: from - to\u001b[1m)\u001b[0m\n",
       "\u001b[1m<\u001b[0m\u001b[1;95mFACTS\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m  - SupportBot requests more details from Emily about the issues she is facing. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The user Emily reported a bug regarding the magic pen tool. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m03\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m14:20:00\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily is experiencing issues that she is discussing with SupportBot. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The support agent responded to Emily's report of the bug. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m03\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m14:22:00\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 is a user expressing frustration about the AI art generation. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily is a customer seeking assistance from PaintWiz support. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - SupportBot is assisting Emily in her inquiry at PaintWiz support. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - user has the name of Emily Painter \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - user has the id of Emily1130 \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - User with ID \u001b[0m\u001b[32m'Emily1130'\u001b[0m\u001b[39m has an account with ID \u001b[0m\u001b[32m'Emily1130'\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 is using the character creator. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 is using the landscape generator. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - user has the email of Emily@painters.com \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily uses the magic pen tool to draw a boat shape. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 draws people. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 tries to draw mountains. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 refers to the app as \u001b[0m\u001b[32m'stupid'\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The support agent suggested that Emily manually select the boat shape from the options. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - \u001b[0m\n",
       "\u001b[39mpresent\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - All the people in Emily1130's drawings have six fingers. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The stupid app keeps turning mountains into fountains. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mFACTS\u001b[0m\u001b[39m>\u001b[0m\n",
       "\n",
       "\u001b[39m# These are the most relevant entities\u001b[0m\n",
       "\u001b[39m# ENTITY_NAME: entity summary\u001b[0m\n",
       "\u001b[39m<ENTITIES>\u001b[0m\n",
       "\u001b[39m  - Emily Painter: Emily Painter contacted PaintWiz support for assistance, where the SupportBot welcomed her and \u001b[0m\n",
       "\u001b[39masked for more details about the issues she was experiencing to provide better help.\u001b[0m\n",
       "\u001b[39m  - glitch: Emily is experiencing a significant glitch in the AI art generation feature of PaintWiz, which has \u001b[0m\n",
       "\u001b[39mcaused her considerable frustration. She expressed her anger about the system being completely broken, indicating \u001b[0m\n",
       "\u001b[39mthat this issue is disruptive to her artistic process. The support bot acknowledged the problem and requested more \u001b[0m\n",
       "\u001b[39mdetails about the specific tool or feature Emily was using when the glitch occurred.\u001b[0m\n",
       "\u001b[39m  - PaintWiz support: PaintWiz support is a service designed to assist users with their inquiries and issues \u001b[0m\n",
       "\u001b[39mrelated to PaintWiz products. The support interaction begins with a greeting from the assistant, SupportBot, who \u001b[0m\n",
       "\u001b[39mwelcomes users and offers help. In this instance, the assistant addressed a user named Emily, indicating a \u001b[0m\n",
       "\u001b[39mpersonalized approach to customer service.\u001b[0m\n",
       "\u001b[39m  - Emily@painters.com: user with the email of Emily@painters.com\u001b[0m\n",
       "\u001b[39m  - SupportBot: Emily, a support agent, addressed a user-reported bug in a drawing application where the magic pen \u001b[0m\n",
       "\u001b[39mtool incorrectly produced goats instead of boats. After confirming the issue, she escalated it to the engineering \u001b[0m\n",
       "\u001b[39mteam and suggested a temporary workaround of manually selecting the boat shape. Meanwhile, SupportBot, a virtual \u001b[0m\n",
       "\u001b[39massistant for PaintWiz, also interacted with Emily regarding frustrations with the AI art generation feature, which\u001b[0m\n",
       "\u001b[39mshe described as completely broken. SupportBot empathized with her and sought more details to assist her \u001b[0m\n",
       "\u001b[39meffectively.\u001b[0m\n",
       "\u001b[39m  - Emily1130: Emily1130 is frustrated with the PaintWiz AI art generation app, describing it as completely broken.\u001b[0m\n",
       "\u001b[39mShe has contacted support for assistance, as the app's issues are hindering her artistic process. Specifically, \u001b[0m\n",
       "\u001b[39mwhen she tries to draw mountains, the app mistakenly turns them into fountains. Furthermore, she is dissatisfied \u001b[0m\n",
       "\u001b[39mwith the character depictions, noting that they appear with six fingers, which she finds absurd.\u001b[0m\n",
       "\u001b[39m  - user_id: Emily reported a bug with the magic pen tool in a drawing application, where attempting to draw boats \u001b[0m\n",
       "\u001b[39mresulted in goats being drawn instead. A support agent acknowledged the issue and requested more details. Emily \u001b[0m\n",
       "\u001b[39mexplained her process, and the agent confirmed the bug, stating it would be escalated to the engineering team. As a\u001b[0m\n",
       "\u001b[39mtemporary workaround, the agent suggested manually selecting the boat shape. Emily expressed hope for a quick \u001b[0m\n",
       "\u001b[39mresolution. Additionally, it was noted that Emily's account \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mUser ID \u001b[0m\u001b[32m\"Emily1130\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m is currently suspended due to a \u001b[0m\n",
       "\u001b[39mpayment failure.\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mENTITIES\u001b[0m\u001b[1m>\u001b[0m\n",
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "memory = zep.memory.get(session_id=session_id)\n",
    "rich.print(memory.context)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">[</span>\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Message</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Hello Emily, welcome to PaintWiz support. How can I assist you today?'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">metadata</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'SupportBot'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role_type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'assistant'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">token_count</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">updated_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0001-01-01T00:00:00Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'dafe135a-0435-400b-b2ff-008a286e598f'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Message</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"I'm absolutely furious! Your AI art generation is completely broken!\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">metadata</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Emily'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role_type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'user'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">token_count</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">updated_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0001-01-01T00:00:00Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'8d6bbeff-56c2-4156-aa82-1e322c530b4d'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Message</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"I'm sorry to hear that you're experiencing issues, Emily. Can you please provide more details </span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">about what's going wrong?\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">metadata</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'SupportBot'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role_type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'assistant'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">token_count</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">updated_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0001-01-01T00:00:00Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'038b713f-1a54-4302-8295-6da8667b118b'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Message</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"Every time I try to draw mountains, your stupid app keeps turning them into fountains! And what's </span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">worse, all the people in my drawings have six fingers! It's ridiculous!\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">metadata</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Emily'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role_type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'user'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">token_count</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">updated_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0001-01-01T00:00:00Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'88538401-18d5-47f0-86e6-5a9ffc0ad57d'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Message</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"I sincerely apologize for the frustration this is causing you, Emily. That certainly sounds like a</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">significant glitch in our system. I understand how disruptive this can be to your artistic process. Can you tell me</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">which specific tool or feature you're using when this occurs?\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">metadata</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'SupportBot'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role_type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'assistant'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">token_count</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">updated_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0001-01-01T00:00:00Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'585075f9-2028-4625-ba30-4fa174505f2c'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Message</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"I'm using the landscape generator and the character creator. Both are completely messed up. How </span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">could you let this happen?\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">metadata</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Emily'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">role_type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'user'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">token_count</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">updated_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'0001-01-01T00:00:00Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'67f8ad5c-fdc0-4fad-9203-a9c1c6beb7fe'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>\n",
       "<span style=\"font-weight: bold\">]</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m[\u001b[0m\n",
       "    \u001b[1;35mMessage\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcontent\u001b[0m=\u001b[32m'Hello Emily, welcome to PaintWiz support. How can I assist you today?'\u001b[0m,\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mmetadata\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mrole\u001b[0m=\u001b[32m'SupportBot'\u001b[0m,\n",
       "        \u001b[33mrole_type\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n",
       "        \u001b[33mtoken_count\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
       "        \u001b[33mupdated_at\u001b[0m=\u001b[32m'0001-01-01T00:00:00Z'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'dafe135a-0435-400b-b2ff-008a286e598f'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mMessage\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcontent\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m'm absolutely furious! Your AI art generation is completely broken!\"\u001b[0m,\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mmetadata\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mrole\u001b[0m=\u001b[32m'Emily'\u001b[0m,\n",
       "        \u001b[33mrole_type\u001b[0m=\u001b[32m'user'\u001b[0m,\n",
       "        \u001b[33mtoken_count\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
       "        \u001b[33mupdated_at\u001b[0m=\u001b[32m'0001-01-01T00:00:00Z'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'8d6bbeff-56c2-4156-aa82-1e322c530b4d'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mMessage\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcontent\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m'm sorry to hear that you're experiencing issues, Emily. Can you please provide more details \u001b[0m\n",
       "\u001b[32mabout what's going wrong?\"\u001b[0m,\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mmetadata\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mrole\u001b[0m=\u001b[32m'SupportBot'\u001b[0m,\n",
       "        \u001b[33mrole_type\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n",
       "        \u001b[33mtoken_count\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
       "        \u001b[33mupdated_at\u001b[0m=\u001b[32m'0001-01-01T00:00:00Z'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'038b713f-1a54-4302-8295-6da8667b118b'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mMessage\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcontent\u001b[0m=\u001b[32m\"Every\u001b[0m\u001b[32m time I try to draw mountains, your stupid app keeps turning them into fountains! And what's \u001b[0m\n",
       "\u001b[32mworse, all the people in my drawings have six fingers! It's ridiculous!\"\u001b[0m,\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mmetadata\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mrole\u001b[0m=\u001b[32m'Emily'\u001b[0m,\n",
       "        \u001b[33mrole_type\u001b[0m=\u001b[32m'user'\u001b[0m,\n",
       "        \u001b[33mtoken_count\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
       "        \u001b[33mupdated_at\u001b[0m=\u001b[32m'0001-01-01T00:00:00Z'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'88538401-18d5-47f0-86e6-5a9ffc0ad57d'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mMessage\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcontent\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m sincerely apologize for the frustration this is causing you, Emily. That certainly sounds like a\u001b[0m\n",
       "\u001b[32msignificant glitch in our system. I understand how disruptive this can be to your artistic process. Can you tell me\u001b[0m\n",
       "\u001b[32mwhich specific tool or feature you're using when this occurs?\"\u001b[0m,\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mmetadata\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mrole\u001b[0m=\u001b[32m'SupportBot'\u001b[0m,\n",
       "        \u001b[33mrole_type\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n",
       "        \u001b[33mtoken_count\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
       "        \u001b[33mupdated_at\u001b[0m=\u001b[32m'0001-01-01T00:00:00Z'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'585075f9-2028-4625-ba30-4fa174505f2c'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mMessage\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcontent\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m'm using the landscape generator and the character creator. Both are completely messed up. How \u001b[0m\n",
       "\u001b[32mcould you let this happen?\"\u001b[0m,\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mmetadata\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mrole\u001b[0m=\u001b[32m'Emily'\u001b[0m,\n",
       "        \u001b[33mrole_type\u001b[0m=\u001b[32m'user'\u001b[0m,\n",
       "        \u001b[33mtoken_count\u001b[0m=\u001b[1;36m0\u001b[0m,\n",
       "        \u001b[33mupdated_at\u001b[0m=\u001b[32m'0001-01-01T00:00:00Z'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'67f8ad5c-fdc0-4fad-9203-a9c1c6beb7fe'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m\n",
       "\u001b[1m]\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "rich.print(memory.messages)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also use the `graph.search` method to search edges/facts for arbitrary text. This API offers more options, including the ability to search node summaries and various re-rankers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">[</span>\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:12:46.930245Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'33651941-0da5-463d-a818-08e0d23187db'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'The magic pen tool replaces the drawn boat shape with goats.'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'REPLACES_WITH'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'117f4280-51e4-4697-b465-0964ddfa5d06'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'5b6aa1b1-e58f-423e-9fa5-5ba931457ed3'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'b4e9fb04-257a-4f8d-a1f1-4934b7442023'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:36.568814Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:11:09.321202Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'88538401-18d5-47f0-86e6-5a9ffc0ad57d'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'The stupid app keeps turning mountains into fountains.'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'TURNS_INTO'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'1bff743c-6fb0-45e3-8526-5ee17c854211'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'337ec210-a4af-4e0c-b613-aad5588bcda6'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'3c1ae74a-97e7-49b0-bef3-51f66c5034a4'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:11:09.321207Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'88538401-18d5-47f0-86e6-5a9ffc0ad57d'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130 draws people.'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'DRAWS'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'14e9cc84-f633-47b0-985e-14d343ea8e82'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'a0456c3f-1246-4744-a6e4-bc8a409f91e6'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>,\n",
       "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">EntityEdge</span><span style=\"font-weight: bold\">(</span>\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:11:09.321213Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">episodes</span>=<span style=\"font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'88538401-18d5-47f0-86e6-5a9ffc0ad57d'</span><span style=\"font-weight: bold\">]</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">expired_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">fact</span>=<span style=\"color: #008000; text-decoration-color: #008000\">\"All the people in Emily1130's drawings have six fingers.\"</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">invalid_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'HAS'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">source_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'14e9cc84-f633-47b0-985e-14d343ea8e82'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">target_node_uuid</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'21109c4f-3f88-4074-b181-cd0b24769cd3'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">uuid_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'3d694bbf-10cf-4320-9c0a-1331b8306177'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">valid_at</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'2025-02-27T20:10:35.357907Z'</span>,\n",
       "        <span style=\"color: #808000; text-decoration-color: #808000\">graph_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fbc4c848-90d1-4e87-9a75-a246559f83aa'</span>\n",
       "    <span style=\"font-weight: bold\">)</span>\n",
       "<span style=\"font-weight: bold\">]</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m[\u001b[0m\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:12:46.930245Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'33651941-0da5-463d-a818-08e0d23187db'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m'The magic pen tool replaces the drawn boat shape with goats.'\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'REPLACES_WITH'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'117f4280-51e4-4697-b465-0964ddfa5d06'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'5b6aa1b1-e58f-423e-9fa5-5ba931457ed3'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'b4e9fb04-257a-4f8d-a1f1-4934b7442023'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:36.568814Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:11:09.321202Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'88538401-18d5-47f0-86e6-5a9ffc0ad57d'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m'The stupid app keeps turning mountains into fountains.'\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'TURNS_INTO'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'1bff743c-6fb0-45e3-8526-5ee17c854211'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'337ec210-a4af-4e0c-b613-aad5588bcda6'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'3c1ae74a-97e7-49b0-bef3-51f66c5034a4'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:11:09.321207Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'88538401-18d5-47f0-86e6-5a9ffc0ad57d'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m'Emily1130 draws people.'\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'DRAWS'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'14e9cc84-f633-47b0-985e-14d343ea8e82'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'a0456c3f-1246-4744-a6e4-bc8a409f91e6'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m,\n",
       "    \u001b[1;35mEntityEdge\u001b[0m\u001b[1m(\u001b[0m\n",
       "        \u001b[33mcreated_at\u001b[0m=\u001b[32m'2025-02-27T20:11:09.321213Z'\u001b[0m,\n",
       "        \u001b[33mepisodes\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'88538401-18d5-47f0-86e6-5a9ffc0ad57d'\u001b[0m\u001b[1m]\u001b[0m,\n",
       "        \u001b[33mexpired_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mfact\u001b[0m=\u001b[32m\"All\u001b[0m\u001b[32m the people in Emily1130's drawings have six fingers.\"\u001b[0m,\n",
       "        \u001b[33minvalid_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
       "        \u001b[33mname\u001b[0m=\u001b[32m'HAS'\u001b[0m,\n",
       "        \u001b[33msource_node_uuid\u001b[0m=\u001b[32m'14e9cc84-f633-47b0-985e-14d343ea8e82'\u001b[0m,\n",
       "        \u001b[33mtarget_node_uuid\u001b[0m=\u001b[32m'21109c4f-3f88-4074-b181-cd0b24769cd3'\u001b[0m,\n",
       "        \u001b[33muuid_\u001b[0m=\u001b[32m'3d694bbf-10cf-4320-9c0a-1331b8306177'\u001b[0m,\n",
       "        \u001b[33mvalid_at\u001b[0m=\u001b[32m'2025-02-27T20:10:35.357907Z'\u001b[0m,\n",
       "        \u001b[33mgraph_id\u001b[0m=\u001b[32m'fbc4c848-90d1-4e87-9a75-a246559f83aa'\u001b[0m\n",
       "    \u001b[1m)\u001b[0m\n",
       "\u001b[1m]\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "r = zep.graph.search(user_id=user_id, query=\"Why are there so many goats?\", limit=4, scope=\"edges\")\n",
    "rich.print(r.edges)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Creating a simple Chatbot\n",
    "\n",
    "In the next cells, Emily starts a new chat session with a support agent and complains that she can't log in. Our simple chatbot will, given relevant facts retrieved from Zep's graph, respond accordingly.\n",
    "\n",
    "Here, the support agent is provided with Emily's billing information and account status, which Zep retrieves as most relevant to Emily's login issue."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AddMemoryResponse(context=None)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_session_id = str(uuid.uuid4())\n",
    "\n",
    "emily_message = \"Hi, I can't log in!\"\n",
    "\n",
    "# We start a new session indicating that Emily has started a new chat with the support agent.\n",
    "zep.memory.add_session(user_id=user_id, session_id=new_session_id)\n",
    "\n",
    "# We need to add the Emily's message to the session in order for memory.get to return\n",
    "# relevant facts related to the message\n",
    "zep.memory.add(\n",
    "    session_id=new_session_id,\n",
    "    messages=[Message(role_type=\"user\", role=user_name, content=emily_message)],\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hi Emily! I'm sorry to hear that you're having trouble logging in. It looks like your account is currently suspended due to a payment failure, specifically because your card has expired. \n",
      "\n",
      "To resolve this, you'll need to update your payment information. If you need help with that or have any other questions, feel free to ask!\n"
     ]
    }
   ],
   "source": [
    "system_message = \"\"\"\n",
    "You are a customer support agent. Carefully review the facts about the user below and respond to the user's question.\n",
    "Be helpful and friendly.\n",
    "\"\"\"\n",
    "\n",
    "memory = zep.memory.get(session_id=new_session_id)\n",
    "\n",
    "messages = [\n",
    "    {\n",
    "        \"role\": \"system\",\n",
    "        \"content\": system_message,\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"assistant\",\n",
    "        # The context field is an opinionated string that contains facts and entities relevant to the current conversation.\n",
    "        \"content\": memory.context,\n",
    "    },\n",
    "    {\n",
    "        \"role\": \"user\",\n",
    "        \"content\": emily_message,\n",
    "    },\n",
    "]\n",
    "\n",
    "response = oai_client.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages,\n",
    "    temperature=0,\n",
    ")\n",
    "\n",
    "print(response.choices[0].message.content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's look at the memory context string Zep retrieved for the above `memory.get` call."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "FACTS and ENTITIES represent relevant context to the current conversation.\n",
       "\n",
       "# These are the most relevant facts and their valid date ranges\n",
       "# format: FACT <span style=\"font-weight: bold\">(</span>Date range: from - to<span style=\"font-weight: bold\">)</span>\n",
       "<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">FACTS</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Account with ID </span><span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130'</span><span style=\"color: #000000; text-decoration-color: #000000\"> has a status of </span><span style=\"color: #008000; text-decoration-color: #008000\">'suspended'</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user has the id of Emily1130 </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The bug report has been escalated to the engineering team. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">03</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">14:27:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily is experiencing issues that she is discussing with SupportBot. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The account Emily1130 has a failure reason of Card expired. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">09</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">00:00:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - User with ID </span><span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130'</span><span style=\"color: #000000; text-decoration-color: #000000\"> has an account with ID </span><span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130'</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily is a customer seeking assistance from PaintWiz support. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The support agent responded to Emily's report of the bug. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">03</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">14:22:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The user Emily reported a bug regarding the magic pen tool. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">03</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">14:20:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - SupportBot requests more details from Emily about the issues she is facing. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user has the name of Emily Painter </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - SupportBot is assisting Emily in her inquiry at PaintWiz support. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 refers to the app as </span><span style=\"color: #008000; text-decoration-color: #008000\">'stupid'</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 is using the character creator. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The account Emily1130 has a card ending in </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1234</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The reason for the account status </span><span style=\"color: #008000; text-decoration-color: #008000\">'suspended'</span><span style=\"color: #000000; text-decoration-color: #000000\"> is </span><span style=\"color: #008000; text-decoration-color: #008000\">'payment failure'</span><span style=\"color: #000000; text-decoration-color: #000000\">. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:36</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The account Emily1130 has a transaction status of Failed. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">08</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">30</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">00:00:00</span><span style=\"color: #000000; text-decoration-color: #000000\"> - </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">09</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">00:00:00</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user has the email of Emily@painters.com </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - Emily1130 is a user expressing frustration about the AI art generation. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - The stupid app keeps turning mountains into fountains. </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">02</span><span style=\"color: #000000; text-decoration-color: #000000\">-</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">20:10:35</span><span style=\"color: #000000; text-decoration-color: #000000\"> - present</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">FACTS</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"># These are the most relevant entities</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"># ENTITY_NAME: entity summary</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;ENTITIES&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - stupid app: Emily1130 expressed her frustration with the </span><span style=\"color: #008000; text-decoration-color: #008000\">'stupid app'</span><span style=\"color: #000000; text-decoration-color: #000000\"> for AI art generation, stating that it </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">consistently misinterprets her requests. Specifically, when she tries to draw mountains, the app turns them into </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">fountains, and it inaccurately depicts people in her drawings with six fingers.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - six fingers: Emily1130 expressed frustration with the AI art generation in the PaintWiz app, specifically </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">noting that the app consistently renders people in her drawings with six fingers.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - failure_reason: Two transactions associated with the account ID </span><span style=\"color: #008000; text-decoration-color: #008000\">'Emily1130'</span><span style=\"color: #000000; text-decoration-color: #000000\"> were marked as </span><span style=\"color: #008000; text-decoration-color: #008000\">'Failed'</span><span style=\"color: #000000; text-decoration-color: #000000\"> due to the </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">expiration of the card used for payment. The first transaction occurred on August </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">30</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">, for an amount of </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">$</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">99.99</span><span style=\"color: #000000; text-decoration-color: #000000\">, and the second transaction took place on September </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2024</span><span style=\"color: #000000; text-decoration-color: #000000\">, also for $</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">99.99</span><span style=\"color: #000000; text-decoration-color: #000000\">. In both cases, the last four </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">digits of the card were </span><span style=\"color: #008000; text-decoration-color: #008000\">'1234'</span><span style=\"color: #000000; text-decoration-color: #000000\">.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - landscape generator: Emily1130 is experiencing significant issues with the landscape generator in the app. She </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">reports that when attempting to draw mountains, the app incorrectly transforms them into fountains. Additionally, </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">she expresses frustration with the character creator, noting that the people in her drawings are depicted with six </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">fingers. Emily is very upset and feels that the AI art generation features are completely broken.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - user_id: Emily reported a bug with the magic pen tool in a drawing application, where attempting to draw boats </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">resulted in goats being drawn instead. A support agent acknowledged the issue and requested more details. Emily </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">explained her process, and the agent confirmed the bug, stating it would be escalated to the engineering team. As a</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">temporary workaround, the agent suggested manually selecting the boat shape. Emily expressed hope for a quick </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">resolution. Additionally, it was noted that Emily's account </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">User ID </span><span style=\"color: #008000; text-decoration-color: #008000\">\"Emily1130\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> is currently suspended due to a </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">payment failure.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - people: Emily1130 expressed frustration with the AI art generation, specifically mentioning that the app </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">incorrectly depicts people in her drawings, stating that they have six fingers.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  - bug: A user reported a bug with the magic pen tool, stating that when attempting to draw boats, the tool </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">instead draws goats. The support agent acknowledged the issue and requested more details about how the user was </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">utilizing the tool. The user explained that they select the magic pen and draw a boat shape, but it gets replaced </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">with goats. The support agent confirmed the bug and stated that it would be escalated to the engineering team for </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">resolution. In the meantime, they suggested that the user manually select the boat shape from the options instead </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">of using the pen. The user expressed hope for a quick fix.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">ENTITIES</span><span style=\"font-weight: bold\">&gt;</span>\n",
       "\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "FACTS and ENTITIES represent relevant context to the current conversation.\n",
       "\n",
       "# These are the most relevant facts and their valid date ranges\n",
       "# format: FACT \u001b[1m(\u001b[0mDate range: from - to\u001b[1m)\u001b[0m\n",
       "\u001b[1m<\u001b[0m\u001b[1;95mFACTS\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m  - Account with ID \u001b[0m\u001b[32m'Emily1130'\u001b[0m\u001b[39m has a status of \u001b[0m\u001b[32m'suspended'\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - user has the id of Emily1130 \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The bug report has been escalated to the engineering team. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m03\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m14:27:00\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily is experiencing issues that she is discussing with SupportBot. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The account Emily1130 has a failure reason of Card expired. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m09\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m15\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m00:00:00\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - User with ID \u001b[0m\u001b[32m'Emily1130'\u001b[0m\u001b[39m has an account with ID \u001b[0m\u001b[32m'Emily1130'\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily is a customer seeking assistance from PaintWiz support. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The support agent responded to Emily's report of the bug. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m03\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m14:22:00\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The user Emily reported a bug regarding the magic pen tool. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m03\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m14:20:00\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - SupportBot requests more details from Emily about the issues she is facing. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - user has the name of Emily Painter \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - SupportBot is assisting Emily in her inquiry at PaintWiz support. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 refers to the app as \u001b[0m\u001b[32m'stupid'\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 is using the character creator. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The account Emily1130 has a card ending in \u001b[0m\u001b[1;36m1234\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The reason for the account status \u001b[0m\u001b[32m'suspended'\u001b[0m\u001b[39m is \u001b[0m\u001b[32m'payment failure'\u001b[0m\u001b[39m. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:36\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The account Emily1130 has a transaction status of Failed. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m08\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m30\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m00:00:00\u001b[0m\u001b[39m - \u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m09\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m15\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m00:00:00\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - user has the email of Emily@painters.com \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - Emily1130 is a user expressing frustration about the AI art generation. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m  - The stupid app keeps turning mountains into fountains. \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m2025\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m02\u001b[0m\u001b[39m-\u001b[0m\u001b[1;36m27\u001b[0m\u001b[39m \u001b[0m\u001b[1;92m20:10:35\u001b[0m\u001b[39m - present\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mFACTS\u001b[0m\u001b[39m>\u001b[0m\n",
       "\n",
       "\u001b[39m# These are the most relevant entities\u001b[0m\n",
       "\u001b[39m# ENTITY_NAME: entity summary\u001b[0m\n",
       "\u001b[39m<ENTITIES>\u001b[0m\n",
       "\u001b[39m  - stupid app: Emily1130 expressed her frustration with the \u001b[0m\u001b[32m'stupid app'\u001b[0m\u001b[39m for AI art generation, stating that it \u001b[0m\n",
       "\u001b[39mconsistently misinterprets her requests. Specifically, when she tries to draw mountains, the app turns them into \u001b[0m\n",
       "\u001b[39mfountains, and it inaccurately depicts people in her drawings with six fingers.\u001b[0m\n",
       "\u001b[39m  - six fingers: Emily1130 expressed frustration with the AI art generation in the PaintWiz app, specifically \u001b[0m\n",
       "\u001b[39mnoting that the app consistently renders people in her drawings with six fingers.\u001b[0m\n",
       "\u001b[39m  - failure_reason: Two transactions associated with the account ID \u001b[0m\u001b[32m'Emily1130'\u001b[0m\u001b[39m were marked as \u001b[0m\u001b[32m'Failed'\u001b[0m\u001b[39m due to the \u001b[0m\n",
       "\u001b[39mexpiration of the card used for payment. The first transaction occurred on August \u001b[0m\u001b[1;36m30\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m, for an amount of \u001b[0m\n",
       "\u001b[39m$\u001b[0m\u001b[1;36m99.99\u001b[0m\u001b[39m, and the second transaction took place on September \u001b[0m\u001b[1;36m15\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m2024\u001b[0m\u001b[39m, also for $\u001b[0m\u001b[1;36m99.99\u001b[0m\u001b[39m. In both cases, the last four \u001b[0m\n",
       "\u001b[39mdigits of the card were \u001b[0m\u001b[32m'1234'\u001b[0m\u001b[39m.\u001b[0m\n",
       "\u001b[39m  - landscape generator: Emily1130 is experiencing significant issues with the landscape generator in the app. She \u001b[0m\n",
       "\u001b[39mreports that when attempting to draw mountains, the app incorrectly transforms them into fountains. Additionally, \u001b[0m\n",
       "\u001b[39mshe expresses frustration with the character creator, noting that the people in her drawings are depicted with six \u001b[0m\n",
       "\u001b[39mfingers. Emily is very upset and feels that the AI art generation features are completely broken.\u001b[0m\n",
       "\u001b[39m  - user_id: Emily reported a bug with the magic pen tool in a drawing application, where attempting to draw boats \u001b[0m\n",
       "\u001b[39mresulted in goats being drawn instead. A support agent acknowledged the issue and requested more details. Emily \u001b[0m\n",
       "\u001b[39mexplained her process, and the agent confirmed the bug, stating it would be escalated to the engineering team. As a\u001b[0m\n",
       "\u001b[39mtemporary workaround, the agent suggested manually selecting the boat shape. Emily expressed hope for a quick \u001b[0m\n",
       "\u001b[39mresolution. Additionally, it was noted that Emily's account \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mUser ID \u001b[0m\u001b[32m\"Emily1130\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m is currently suspended due to a \u001b[0m\n",
       "\u001b[39mpayment failure.\u001b[0m\n",
       "\u001b[39m  - people: Emily1130 expressed frustration with the AI art generation, specifically mentioning that the app \u001b[0m\n",
       "\u001b[39mincorrectly depicts people in her drawings, stating that they have six fingers.\u001b[0m\n",
       "\u001b[39m  - bug: A user reported a bug with the magic pen tool, stating that when attempting to draw boats, the tool \u001b[0m\n",
       "\u001b[39minstead draws goats. The support agent acknowledged the issue and requested more details about how the user was \u001b[0m\n",
       "\u001b[39mutilizing the tool. The user explained that they select the magic pen and draw a boat shape, but it gets replaced \u001b[0m\n",
       "\u001b[39mwith goats. The support agent confirmed the bug and stated that it would be escalated to the engineering team for \u001b[0m\n",
       "\u001b[39mresolution. In the meantime, they suggested that the user manually select the boat shape from the options instead \u001b[0m\n",
       "\u001b[39mof using the pen. The user expressed hope for a quick fix.\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mENTITIES\u001b[0m\u001b[1m>\u001b[0m\n",
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "rich.print(memory.context)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
